package waveData
{
	public class LoopData
	{
		public var position:int = 0;
		private var _timeList:Vector.<uint>;
		private var _volumeList:Vector.<Number>;
		
		public function LoopData()
		{
			_timeList = new Vector.<uint>();
			_volumeList = new Vector.<Number>();
		}
		
		public function add(time:uint, volume:Number):void
		{
			_timeList.push(time);
			_volumeList.push(volume);
		}
		
		public function setLast(time:uint):void	
		{
			if (_timeList.length == 0) return void;
			for (var i:int = _timeList.length - 1; i > 0; i--)
			{
				if (_timeList[i] >= time)
				{
					_timeList.pop();
					_volumeList.pop();
				}
			}
			add(time, 0);			
		}
		
		public function clone():LoopData
		{
			var a:LoopData = new LoopData();
			for (var i:int = 0; i < _timeList.length; i++)
			{
				a.add(new uint(_timeList[i]), new Number(_volumeList[i]));
			}
			return a;
		}
		
		public function getVolume():Number
		{
			return _volumeList[position];
		}
		
		public function getTime():int
		{
			return _timeList[position];
		}
		
		public function getTime2(i:int):int
		{
			return _timeList[i];
		}
		
		public function get length():uint
		{
			return _timeList.length;
		}

		public function get timeList():Vector.<uint>
		{
			return _timeList;
		}

		public function set timeList(value:Vector.<uint>):void
		{
			_timeList = value;
		}

		public function get volumeList():Vector.<Number>
		{
			return _volumeList;
		}

		public function set volumeList(value:Vector.<Number>):void
		{
			_volumeList = value;
		}

	}
}